
<template>

  <div>
    <van-nav-bar
      title="修改头像"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <van-form @submit="onSubmit">


      <van-uploader style="margin-left:2.5rem; margin-top:.5rem" :after-read="afterRead" />

      <div style="margin: 16px;">
        <van-button round block type="primary" native-type="submit">
          提交
        </van-button>
      </div>
    </van-form>
  </div>



</template>

<script>
export default {
  name: "edit",
  created(){

    this.loadData()

  },
  setup() {
    const onClickLeft = () => history.back();
    return {
      onClickLeft,
    };

      const afterRead = (file) => {
        // 此时可以自行将文件上传至服务器
        console.log(file);
      };

      return {
        afterRead,
      };




  },
  data(){
    return{
      user:{
        name:"",
        phone:"",
        sex:"",
      }
    }
  },
  methods:{

    loadData(){
      let _this = this
      this.$axios.post("/user/findUserData").then(
        function (response) {
          console.log(response)

          _this.user = response.data.data.user

        }
      )
    },
    onSubmit(){
      let _this = this
      this.$axios.post("/user/editUser",this.user).then(
        function (response) {
          console.log(response)

          _this.user = response.data.data.user

        }
      )
    },
    jump(path){

      this.$router.push(path)
    }
  }
}
</script>


<style scoped>

</style>
